using System;
using System.Collections.Generic;
using OS.Infrastructure.Domain;

namespace TaskKernel.Domain
{
    public abstract class AggregateRoot : AbstractEntity
    {
        private readonly List<Event> _changes = new List<Event>();

        public virtual IEnumerable<Event> GetUncommittedChanges()
        {
            return _changes;
        }

        public virtual void MarkChangesAsCommitted()
        {
            _changes.Clear();
        }

        public virtual void ApplyChange(Event @event)
        {
            _changes.Add(@event);
        }
    }
    public class Event : Message
    {
        public virtual Account Owner { get; protected set; }
        public virtual DateTime Time { get; protected set; }
        public virtual string Text { get; protected set; }
    }

    public sealed class SystemEvent : Event
    {
        public SystemEvent(Account eventOwner, string text)
        {
            Text = text;
            Time = DateTime.Now;
            Owner = eventOwner;
        }
    }
}